﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BenefitHelper
{
    /// <summary>
    /// 输入导入入口
    /// </summary>
    public class EnterPoint
    {
        /// <summary>
        /// 导入某日数据
        /// </summary>
        /// <param name="pdate"></param>
        public void Work(string pdate)
        {
            DB.DBManager db = new DB.DBManager();
            Sys.TradeHistory th = new Sys.TradeHistory();
            if (!th.HasChangeIntoDb(pdate, db))
            {
                #region 保存导入时间
                int tradeHistoryId = th.Insert(pdate, db);//访问数据库

                DateTime dd = Convert.ToDateTime(pdate.Substring(0, 4) + "-" + pdate.Substring(4, 2) + "-" + pdate.Substring(6));

                #endregion

                #region 开始结算时设定系统忙，不能被查询
                BenefitHelper.Sys.ServerStatus.SetServerStatus(Convert.ToInt32(BenefitHelper.Sys._ServerStatus.Bussy));
                #endregion

                int connectionStringCount = System.Configuration.ConfigurationManager.ConnectionStrings.Count;
                for (int i = 0; i < connectionStringCount; i++)
                {
                    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[i].ConnectionString;
                    if (System.Configuration.ConfigurationManager.ConnectionStrings[i].ProviderName.Equals("System.Data.OracleClient"))
                    {
                        //connectionString.Debug();
                        Common.ADO.Tools.OracleHelper.connectionString = connectionString;
                        #region 保存原始数据

                        #region 保存Server中新的交易所
                        List<Data.ServerData.T_Exchange> exchanges = this.GetUnRegistExchanges(db);
                        foreach (Data.ServerData.T_Exchange exchange in exchanges)
                        {
                            Sys.Exchange t = new Sys.Exchange();
                            t.InsertIntoBenefitFromServer(exchange.ExchangeID, exchange.ExchangeName, db);
                        }
                        #endregion

                        #region 保存Server中新的经纪公司
                        Sys.Broker _broker = new Sys.Broker();
                        _broker.InitBrokers(db);
                        #endregion

                        #region 保存Server中新的品种
                        List<Data.ServerData.T_Product> products = this.GetUnRegistProducts(db);
                        foreach (Data.ServerData.T_Product product in products)
                        {
                            Sys.Product t = new Sys.Product();
                            t.InsertIntoBenefitFromServer(product.ProductID, product.ExchangeID, db);
                        }
                        #endregion

                        #region 保存Server中新的合约
                        List<Data.ServerData.T_Instrument> instruments = this.GetUnRegistInstruments(db);
                        foreach (Data.ServerData.T_Instrument instrument in instruments)
                        {
                            Sys.Instrument t = new Sys.Instrument();
                            t.InsertIntoBenefitFromServer(instrument.ProductID, instrument.ExchangeID, instrument.InstrumentID, db);
                        }
                        #endregion

                        #region 保存Server中新的账号
                        List<Data.ServerData.T_Account> accounts = this.GetUnRegistAccounts(db);
                        foreach (Data.ServerData.T_Account account in accounts)
                        {
                            Sys.Account t = new Sys.Account();
                            t.InsertIntoBenefitFromServer(account.LoginAccount);
                        }
                        #endregion

                        #region 保存Server中新的出入金明细
                        Data.ServerData.T_CashIO_History h = new Data.ServerData.T_CashIO_History();
                        h.CopyServerCashIOHistoryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的结算资金信息
                        Data.ServerData.T_SettlementMoney tsm = new Data.ServerData.T_SettlementMoney();
                        tsm.CopyServerSettlementMoneyDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的持仓明细
                        Data.ServerData.T_PositionDetail_History tph = new Data.ServerData.T_PositionDetail_History();
                        tph.CopyServerPositionDetailHistoryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的持仓汇总
                        Data.ServerData.T_PositionSummaryDelivery tpsd = new Data.ServerData.T_PositionSummaryDelivery();
                        tpsd.CopyServerPositionSummaryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的成交明细
                        Data.ServerData.T_TradeDetail_History tdh = new Data.ServerData.T_TradeDetail_History();
                        tdh.CopyServerTradeDetailHistoryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的成交汇总
                        Data.ServerData.T_TradeDetail_Summary tds = new Data.ServerData.T_TradeDetail_Summary();
                        tds.CopyServerTradeSummaryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 保存Server中新的平仓明细
                        Data.ServerData.T_ClosePositionDetail_History cph = new Data.ServerData.T_ClosePositionDetail_History();
                        cph.CopyServerClosePositionDetailHistoryDataIntoBenefit(pdate, db);
                        #endregion

                        #region 交易合约Tick值ok
                        Data.Day.DayWinOrLoseTick tick = new Data.Day.DayWinOrLoseTick();
                        tick.InitTickValue(pdate, tradeHistoryId, db);
                        #endregion


                        #endregion
                    }
                }





                #region 初始化每天的小组交易员关系
                Sys.DayGroupOperators dgop = new Sys.DayGroupOperators();
                dgop.InitDayGroupOperators(dd, db);
                #endregion

                #region 初始化每天的账户交易员关系
                Sys.DayOperatorAccount dgop2 = new Sys.DayOperatorAccount();
                dgop2.InitDayOperatorAccount(dd, db);
                #endregion

                #region 初始化每天的组长组关系
                Sys.DayGroupMaster dgop3 = new Sys.DayGroupMaster();
                dgop3.InitDayGroupMaster(dd, db);
                #endregion


                #region 账号数据变动基本信息ok
                Data.Day.AccountDayChange change = new Data.Day.AccountDayChange();
                change.InitDayAccountDayChange(tradeHistoryId, pdate, db);
                #endregion

                #region 账号数据变动分析信息ok
                Data.Day.AccountDayAnalysis changeAnalysis = new Data.Day.AccountDayAnalysis();
                changeAnalysis.InitAccountDayAnalysis(tradeHistoryId, pdate, db);
                #endregion

                #region 账户合约数据变动基本信息ok
                Data.Day.AccountDayTradeInstrument at = new Data.Day.AccountDayTradeInstrument();
                at.InitDayAccountInstrumentChange(tradeHistoryId, pdate, db);
                #endregion

                #region 账户合约数据变动分析信息ok
                Data.Day.AccountDayTradeInstrumentAnalysis at2 = new Data.Day.AccountDayTradeInstrumentAnalysis();
                at2.InitAccountInstrumentDayAnalysis(tradeHistoryId, pdate, db);
                #endregion

                #region 账户品种数据变动基本信息ok
                Data.Day.AccountDayTradeProduct at3 = new Data.Day.AccountDayTradeProduct();
                at3.InitDayAccountProductChange(tradeHistoryId, pdate, db);
                #endregion

                #region 账户品种数据变动分析信息ok
                Data.Day.AccountDayTradeProductAnalysis at4 = new Data.Day.AccountDayTradeProductAnalysis();
                at4.InitAccountProductDayAnalysis(tradeHistoryId, pdate, db);
                #endregion

                #region 账户持仓信息ok
                Data.Day.AccountDayPositionDelivery aa = new Data.Day.AccountDayPositionDelivery();
                aa.InitAccountDayPositionDelivery(tradeHistoryId, pdate, db);
                #endregion

                #region 账户资金信息ok
                Data.Day.AccountDayMoney money = new Data.Day.AccountDayMoney();
                money.InitDayAccountDayMoney(tradeHistoryId, pdate, db);
                #endregion

                #region 账户分时数据ok
                Data.Day.DayTradeInfo bad8 = new Data.Day.DayTradeInfo();
                bad8.InitDayStateChange(tradeHistoryId, pdate, db);
                #endregion


                #region 开始分析数据



                #region 以下与基本数据无关

                #region 账户月基本数据
                th = th.GetModel(tradeHistoryId, db);
                Data.Month.AccountMonthChange monthchange = new Data.Month.AccountMonthChange();
                monthchange.InitMonthAccountChange(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月分析数据
                Data.Month.AccountMonthAnalysis monthchangeAnalysis = new Data.Month.AccountMonthAnalysis();
                monthchangeAnalysis.InitMonthAccountAnalysis(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月合约基本数据
                Data.Month.AccountMonthTradeInstrument monthinstrument = new Data.Month.AccountMonthTradeInstrument();
                monthinstrument.InitMonthAccountInstrumentChange(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月合约分析数据
                Data.Month.AccountMonthTradeInstrumentAnalysis monthinstrument2 = new Data.Month.AccountMonthTradeInstrumentAnalysis();
                monthinstrument2.InitMonthAccountInstrumentAnalysis(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月品种基本数据
                Data.Month.AccountMonthTradeProduct monthproduct = new Data.Month.AccountMonthTradeProduct();
                monthproduct.InitMonthAccountProductChange(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月品种分析数据
                Data.Month.AccountMonthTradeProductAnalysis monthproduct2 = new Data.Month.AccountMonthTradeProductAnalysis();
                monthproduct2.InitMonthAccountProductAnalysis(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户周均值数据
                Data.Week.AccountAvgWeek week = new Data.Week.AccountAvgWeek();
                week.InitAccountWeekAvg(th.WPdate, th.MPdate, th.YPdate, db);
                #endregion

                #region 账户月均值数据
                Data.Month.AccountMonthAvg month = new Data.Month.AccountMonthAvg();
                month.InitAccountMonthAvg(th.MPdate, th.YPdate, db);
                #endregion



                #region 账户五日均值
                Data.Day.AccountFiveDayAvg cavgd3 = new Data.Day.AccountFiveDayAvg();
                cavgd3.InitAccountFiveDayAvg(tradeHistoryId, pdate, db);
                #endregion

                #region 同批次交易员日均值
                Data.Day.BatchAvgDay bad = new Data.Day.BatchAvgDay();
                bad.InitBatchDayAvg(tradeHistoryId, pdate, db);
                #endregion

                #region 同批次交易员周均值
                Data.Week.BatchAvgWeek bad2 = new Data.Week.BatchAvgWeek();
                bad2.InitBatchWeekAvg(th.WPdate, th.MPdate, th.YPdate, db);
                #endregion

                #region 同批次交易员月均值
                Data.Month.BatchAvgMonth bad3 = new Data.Month.BatchAvgMonth();
                bad3.InitBatchMonthAvg(th.MPdate, th.YPdate, db);
                #endregion

                #region 小组日累计值
                Data.Day.GroupDayChange bad4 = new Data.Day.GroupDayChange();
                bad4.InitGroupDaySum(tradeHistoryId, pdate, db);
                #endregion

                #region 小组日均值
                BenefitHelper.Data.Day.GroupAvgDay gad = new Data.Day.GroupAvgDay();
                gad.InitGroupDayAvg(tradeHistoryId, db);
                #endregion



                #region 小组月累计值
                Data.Month.GroupMonthSum bad5 = new Data.Month.GroupMonthSum();
                bad5.InitGroupMonthSum(th.MPdate, th.YPdate, db);
                #endregion

                #region 小组月均值
                Data.Month.GroupAvgMonth gam = new Data.Month.GroupAvgMonth();
                gam.InitGroupMonthAvg(th.MPdate, th.YPdate, db);

                #endregion

                #region 小组周累计值
                Data.Week.GroupWeekSum bad6 = new Data.Week.GroupWeekSum();
                bad6.InitGroupWeekSum(th.WPdate, th.MPdate, th.YPdate, db);
                #endregion

                #region 小组年累计值
                Data.Year.GroupYearSum bad7 = new Data.Year.GroupYearSum();
                bad7.InitGroupYearSum(th.YPdate, db);
                #endregion

                #region 经纪公司日交易情况
                Data.Day.BrokerageDayTradeInfo bad11 = new Data.Day.BrokerageDayTradeInfo();
                bad11.InitBrokerDayTradeInfo(th.Id, pdate, db);
                #endregion

                #region 经纪公司月交易情况
                Data.Month.BrokerageMonthTradeInfo bad12 = new Data.Month.BrokerageMonthTradeInfo();
                bad12.InitBrokerMonthTradeInfo(th.MPdate, th.YPdate, db);
                #endregion


                #region 账户月资金信息
                Data.Month.AccountMonthMoney bad13 = new Data.Month.AccountMonthMoney();
                bad13.InitAccountMonthMoney(th.MPdate, th.YPdate, db);
                #endregion

                #region 账户年资金信息
                Data.Year.AccountYearMoney bad14 = new Data.Year.AccountYearMoney();
                bad14.InitAccountYearMoney(th.YPdate, db);
                #endregion


                #region 账户周预期
                Data.Month.AccountMonthExpected bad15 = new Data.Month.AccountMonthExpected();
                bad15.InitAccountMonthExpected(th.MPdate, th.YPdate, db);
                #endregion


                #region 账户月预期
                Data.Week.AccountWeekExpected bad16 = new Data.Week.AccountWeekExpected();
                bad16.InitAccountWeekExpected(th.WPdate, th.MPdate, th.YPdate, db);
                #endregion

                #endregion


                #endregion






                #region 初始化小组日均值
                View.GroupDayAvg gda = new View.GroupDayAvg();
                gda.InitGroupAvg(tradeHistoryId, db);
                #endregion

                #region 操作员周均值
                View.OperatorAvgWeek oaw = new View.OperatorAvgWeek();
                oaw.InitOperatorAvgWeek(tradeHistoryId, db);
                #endregion

                #region 初始化交易员日分析数据
                View.OperatorDayChange gda3 = new View.OperatorDayChange();
                gda3.InitOperatorDayChange(tradeHistoryId, db);
                #endregion

                #region 初始化交易员日多空数据
                View.OperatorDayDirectionInfo gda4 = new View.OperatorDayDirectionInfo();
                gda4.InitOperatorDayDirectionInfo(tradeHistoryId, false, db);
                gda4.InitOperatorDayDirectionInfo(tradeHistoryId, true, db);
                #endregion

                #region 初始化交易员日品种交易情况
                View.OperatorDayProductInfo opdayproductinfo = new View.OperatorDayProductInfo();
                opdayproductinfo.IntiOperatorDayProductInfo(tradeHistoryId, db);
                #endregion

                #region 初始化交易员月品种交易情况
                View.OperatorMonthProductInfo opmonthproductinfo = new View.OperatorMonthProductInfo();
                opmonthproductinfo.InitOperatorMonthProductInfo(tradeHistoryId, db);
                #endregion

                #region 初始化交易员年品种交易情况
                View.OperatorYearProductInfo opyearproductinfo = new View.OperatorYearProductInfo();
                opyearproductinfo.InitOperatorYearProductInfo(tradeHistoryId, db);
                #endregion

                #region 初始化交易员日资金信息
                View.OperatorDayMoney moneya = new View.OperatorDayMoney();
                moneya.InitOperatorDayMoney(tradeHistoryId, db);
                #endregion

                #region 初始化交易员月资金信息
                View.OperatorMonthMoney moneyb2 = new View.OperatorMonthMoney();
                moneyb2.InitOperatorMonthMoney(th.MPdate, th.YPdate, db);
                #endregion

                #region 初始化交易员年资金信息
                View.OperatorYearMoney moneyc = new View.OperatorYearMoney();
                moneyc.InitOperatorYearMoney(th.YPdate, db);
                #endregion

                #region 初始化交易员持仓信息
                View.OperatorDayPosition moneyb = new View.OperatorDayPosition();
                moneyb.InitOperatorDayPosition(tradeHistoryId, db);
                #endregion

                #region 初始化交易员Tick数据
                View.OperatorDayTick tick3 = new View.OperatorDayTick();
                tick3.InitOperatorDayTick(tradeHistoryId, db, true);
                tick3.InitOperatorDayTick(tradeHistoryId, db, false);
                #endregion


                #region 初始化交易员月Tick数据
                View.OperatorMonthTick tick4 = new View.OperatorMonthTick();
                tick4.InitOperatorMonthTick(th.MPdate, th.YPdate, db, true);
                tick4.InitOperatorMonthTick(th.MPdate, th.YPdate, db, false);
                #endregion

                #region 初始化交易员年Tick数据
                View.OperatorYearTick tick5 = new View.OperatorYearTick();
                tick5.InitOperatorYearTick(th.YPdate, db, true);
                tick5.InitOperatorYearTick(th.YPdate, db, false);
                #endregion

                #region 初始化交易员五日均值
                View.OperatorFiveDayAvg opavg = new View.OperatorFiveDayAvg();
                opavg.InitOperatorFiveDayAvg(tradeHistoryId, db);
                #endregion

                #region 初始化交易员月值
                View.OperatorMonthAvg opmonthavg = new View.OperatorMonthAvg();
                opmonthavg.InitOperatorMonthAvg(tradeHistoryId, db);
                #endregion

                #region 初始化同批次交易员年均值
                Data.Year.BatchAvgYear bay = new Data.Year.BatchAvgYear();
                bay.InitBatchAvgYear(th.YPdate, db);
                #endregion

                #region  初始化交易员交易情况
                Sys.OperatorInfo info = new Sys.OperatorInfo();
                info.OperatorWorking(tradeHistoryId, db);
                #endregion

                #region 初始化交易员小组排名
                Data.Week.OperatorWeekSort sort = new Data.Week.OperatorWeekSort();
                sort.InitOperatorWeekSort(tradeHistoryId, db);
                #endregion

                #region 初始化小组年均值
                Data.Year.GroupAvgYear gay = new Data.Year.GroupAvgYear();
                gay.InitGroupAvgYear(th.YPdate, db);
                #endregion

                #region 初始化公司日总值
                Data.Day.CompanyDayChange cdc = new Data.Day.CompanyDayChange();
                cdc.InitCompanyDayChange(th.Id, db);
                #endregion





                #region 初始化小组月Tick值
                Data.Month.GroupMonthWinOrLoseTick gay2 = new Data.Month.GroupMonthWinOrLoseTick();
                gay2.InitGroupMonthWinOrLoseTick(th.Id, true, db);
                gay2.InitGroupMonthWinOrLoseTick(th.Id, false, db);
                #endregion

                #region 初始化小组年Tick值
                Data.Year.GroupYearWinOrLoseTick gay3 = new Data.Year.GroupYearWinOrLoseTick();
                gay3.InitGroupYearWinOrLoseTick(th.Id, true, db);
                gay3.InitGroupYearWinOrLoseTick(th.Id, false, db);
                #endregion

                #region 初始化小组五日均值
                View.GroupFiveDayAvg gfda = new View.GroupFiveDayAvg();
                gfda.InitGroupFiveDayAvg(tradeHistoryId, db);
                #endregion



                #region 初始化交易员周总计
                View.OperatorWeekSum opweeksum = new View.OperatorWeekSum();
                opweeksum.InitOperatorWeekSum(tradeHistoryId, db);
                #endregion

                #region 初始化交易月总计
                View.OperatorMonthSum opmonthsum = new View.OperatorMonthSum();
                opmonthsum.InitOperatorMonthSum(th.MPdate, th.YPdate, db);
                #endregion

                #region 初始化交易员年总计
                View.OperatorYearSum oys = new View.OperatorYearSum();
                oys.InitOperatorYearSum(th.Id, db);
                #endregion

                #region 初始化交易员年均值
                View.OperatorYearAvg oys2 = new View.OperatorYearAvg();
                oys2.InitOperatorYearAvg(th.Id, db);
                #endregion

                #region 初始化交易员年预期
                View.OperatorYearExpected oys3 = new View.OperatorYearExpected();
                oys3.InitOperatorYearExpected(th.Id, db);
                #endregion

                #region 初始化交易员周预期
                View.OperatorWeekExpected owe = new View.OperatorWeekExpected();
                owe.InitOperatorWeekExpected(th.Id, db);
                #endregion

                #region  初始化交易员月预期
                View.OperatorMonthExpected ome = new View.OperatorMonthExpected();
                ome.InitOperatorMonthExpected(th.Id, db);
                #endregion

                #region 公司日均值数据
                Data.Day.CompanyAvgDay cavgd = new Data.Day.CompanyAvgDay();
                cavgd.InitCompanyDayAvg(th.Id, db);
                #endregion

                #region 公司周均值数据
                Data.Week.CompanyAvgWeek cavgw = new Data.Week.CompanyAvgWeek();
                cavgw.InitCompanyWeekAvg(th.WPdate, th.MPdate, th.YPdate, db);
                #endregion

                #region 公司月均值数据
                Data.Month.CompanyAvgMonth cmonth = new Data.Month.CompanyAvgMonth();
                cmonth.InitCompanyMonthAvg(th.MPdate, th.YPdate, db);
                #endregion

                #region 公司五日均值数据
                Data.Day.CompanyFiveDayAvg cavgd2 = new Data.Day.CompanyFiveDayAvg();
                cavgd2.InitCompanyFiveDayAvg(th.Id, db);
                #endregion

                #region 初始化公司月总值
                Data.Month.CompanyMonthSum cms = new Data.Month.CompanyMonthSum();
                cms.InitCompanyMonthSum(th.YPdate, th.MPdate, db);
                #endregion


                #region 初始化公司年总值
                Data.Year.CompanyYearSum cys = new Data.Year.CompanyYearSum();
                cys.InitCompanyYearSum(th.YPdate, db);
                #endregion

                #region 初始化公司年均值
                Data.Year.CompanyYearAvg cay = new Data.Year.CompanyYearAvg();
                cay.InitCompanyYearAvg(th.YPdate, db);
                #endregion

                #region 初始化公司周累计
                Data.Week.CompanyWeekSum cws = new Data.Week.CompanyWeekSum();
                cws.InitCompanyWeekSum(th.YPdate, th.WPdate, th.MPdate, db);
                #endregion

                #region 初始化经济公司年累计
                Data.Year.BrokerageYearTradeInfo cws2 = new Data.Year.BrokerageYearTradeInfo();
                cws2.InitBrokerYearTradeInfo(th.YPdate, db);
                #endregion

                new Sys.OperatorCouldSeeGroups().InitOperatorCouldSeeGroups(db);
                #region 结束结算时设定系统空闲
                BenefitHelper.Sys.ServerStatus.SetServerStatus(Convert.ToInt32(BenefitHelper.Sys._ServerStatus.Free));
                #endregion
            }
            db.Dispose();
        }
        /// <summary>
        /// 清除某日交易记录
        /// </summary>
        /// <param name="pdate"></param>
        public void Clear(string pdate, DB.DBManager db)
        {


            #region 删除Server中新的出入金明细
            Data.ServerData.T_CashIO_History h = new Data.ServerData.T_CashIO_History();
            h.DeleteDayCashIOFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的结算信息
            Data.ServerData.T_SettlementMoney tsm = new Data.ServerData.T_SettlementMoney();
            tsm.DeleteDaySettlementMoneyFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的持仓明细
            Data.ServerData.T_PositionDetail_History tph = new Data.ServerData.T_PositionDetail_History();
            tph.DeleteDayPositionDetailHistoryFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的持仓汇总
            Data.ServerData.T_PositionSummaryDelivery tpsd = new Data.ServerData.T_PositionSummaryDelivery();
            tpsd.DeleteDayPositionSummaryFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的成交明细
            Data.ServerData.T_TradeDetail_History tdh = new Data.ServerData.T_TradeDetail_History();
            tdh.DeleteDayTradeDetailHistoryFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的成交汇总
            Data.ServerData.T_TradeDetail_Summary tds = new Data.ServerData.T_TradeDetail_Summary();
            tds.DeleteDayTradeSummaryFromBenefit(pdate, db);
            #endregion

            #region 删除Server中新的平仓明细
            Data.ServerData.T_ClosePositionDetail_History cph = new Data.ServerData.T_ClosePositionDetail_History();
            cph.DeleteDayClosePositionDetailHistoryFromBenefit(pdate, db);
            #endregion

            #region 删除当日的分组情况
            Sys.TradeHistory th2 = new Sys.TradeHistory();
            int tradeHistoryId = th2.GetSettlementModel(pdate, db).Id;
            if (tradeHistoryId == 0)
            {
                return;
            }
            DateTime dd = th2.GetDateTimeFromTradeHistoryId(tradeHistoryId, db);
            new Sys.DayGroupOperators().DeleteDayGroupOperators(dd, db);
            #endregion

            #region 当日有交易的交易员交易天数减一
            Sys.OperatorInfo info = new Sys.OperatorInfo();
            info.UnsetDayWorking(tradeHistoryId, db);
            #endregion

            #region 删除当日的交易员账户分配情况
            new Sys.DayOperatorAccount().DeleteDayOperatorAccount(dd, db);
            #endregion

            #region 删除当日的组长情况
            new Sys.DayGroupMaster().DeleteDayGroupMaster(dd, db);
            #endregion

            #region 删除分析数据

            #region 删除数据变动基本信息
            Data.Day.AccountDayChange change = new Data.Day.AccountDayChange();
            change.Delete(tradeHistoryId, db);
            #endregion

            #region 删除数据变动分析信息
            Data.Day.AccountDayAnalysis changeAnalysis = new Data.Day.AccountDayAnalysis();
            changeAnalysis.Delete(tradeHistoryId, db);
            #endregion

            #region 删除Tick分析信息
            Data.Day.DayWinOrLoseTick tick = new Data.Day.DayWinOrLoseTick();
            tick.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户合约数据变动基本信息
            Data.Day.AccountDayTradeInstrument at = new Data.Day.AccountDayTradeInstrument();
            at.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户合约数据变动分析信息
            Data.Day.AccountDayTradeInstrumentAnalysis at2 = new Data.Day.AccountDayTradeInstrumentAnalysis();
            at2.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户品种数据变动基本信息
            Data.Day.AccountDayTradeProduct at3 = new Data.Day.AccountDayTradeProduct();
            at3.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户品种数据变动分析信息
            Data.Day.AccountDayTradeProductAnalysis at4 = new Data.Day.AccountDayTradeProductAnalysis();
            at4.Delete(tradeHistoryId, db);
            #endregion

            #region 删除日持仓信息
            Data.Day.AccountDayPositionDelivery aa = new Data.Day.AccountDayPositionDelivery();
            aa.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户日资金信息
            Data.Day.AccountDayMoney money = new Data.Day.AccountDayMoney();
            money.Delete(tradeHistoryId, db);
            #endregion

            #region 删除账户月基本数据
            Sys.TradeHistory th3 = new Sys.TradeHistory();
            th3 = th3.GetModel(tradeHistoryId, db);
            Data.Month.AccountMonthChange monthchange = new Data.Month.AccountMonthChange();
            monthchange.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月分析数据
            Data.Month.AccountMonthAnalysis monthchangeAnalysis = new Data.Month.AccountMonthAnalysis();
            monthchangeAnalysis.Delete(th3.MPdate, th3.YPdate, db);
            #endregion


            #region 删除账户月合约基本数据
            Data.Month.AccountMonthTradeInstrument monthinstrument = new Data.Month.AccountMonthTradeInstrument();
            monthinstrument.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月合约分析数据
            Data.Month.AccountMonthTradeInstrumentAnalysis monthinstrument2 = new Data.Month.AccountMonthTradeInstrumentAnalysis();
            monthinstrument2.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月品种基本数据
            Data.Month.AccountMonthTradeProduct monthproduct = new Data.Month.AccountMonthTradeProduct();
            monthproduct.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月品种分析数据
            Data.Month.AccountMonthTradeProductAnalysis monthproduct2 = new Data.Month.AccountMonthTradeProductAnalysis();
            monthproduct2.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户周均值数据
            Data.Week.AccountAvgWeek week = new Data.Week.AccountAvgWeek();
            week.Delete(th3.WPdate, th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月均值数据
            Data.Month.AccountMonthAvg month = new Data.Month.AccountMonthAvg();
            month.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除公司日均值数据
            Data.Day.CompanyAvgDay cavgd = new Data.Day.CompanyAvgDay();
            cavgd.Delete(th3.Id, db);
            #endregion

            #region 删除公司周均值数据
            Data.Week.CompanyAvgWeek cavgw = new Data.Week.CompanyAvgWeek();
            cavgw.Delete(th3.WPdate, th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除公司月均值数据
            Data.Month.CompanyAvgMonth cmonth = new Data.Month.CompanyAvgMonth();
            cmonth.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户五日均值
            Data.Day.AccountFiveDayAvg cavgd3 = new Data.Day.AccountFiveDayAvg();
            cavgd3.Delete(tradeHistoryId, db);
            #endregion

            #region 删除同批次交易员日均值
            Data.Day.BatchAvgDay bad = new Data.Day.BatchAvgDay();
            bad.Delete(tradeHistoryId, db);
            #endregion

            #region 删除同批次交易员周均值
            Data.Week.BatchAvgWeek bad2 = new Data.Week.BatchAvgWeek();
            bad2.Delete(th3.WPdate, th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除同批次交易员月均值
            Data.Month.BatchAvgMonth bad3 = new Data.Month.BatchAvgMonth();
            bad3.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除小组日累计值
            Data.Day.GroupDayChange bad4 = new Data.Day.GroupDayChange();
            bad4.Delete(th3.Id, db);
            #endregion

            #region 删除小组月累计值
            Data.Month.GroupMonthSum bad5 = new Data.Month.GroupMonthSum();
            bad5.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除小组日均值
            BenefitHelper.Data.Day.GroupAvgDay gad = new Data.Day.GroupAvgDay();
            gad.Delete(tradeHistoryId, db);
            #endregion

            #region 删除小组月累计值
            new Data.Month.GroupAvgMonth().Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除小组月Tick值
            Data.Month.GroupMonthWinOrLoseTick gay2 = new Data.Month.GroupMonthWinOrLoseTick();
            gay2.Delete(th3.Id, db);
            #endregion

            #region 删除小组年Tick值
            Data.Year.GroupYearWinOrLoseTick gay3 = new Data.Year.GroupYearWinOrLoseTick();
            gay3.Delete(th3.Id, db);
            #endregion

            #region 删除小组周累计值
            Data.Week.GroupWeekSum bad6 = new Data.Week.GroupWeekSum();
            bad6.Delete(th3.WPdate, th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除小组年累计值
            Data.Year.GroupYearSum bad7 = new Data.Year.GroupYearSum();
            bad7.Delete(th3.YPdate, db);
            #endregion

            #region 删除分时数据
            Data.Day.DayTradeInfo bad8 = new Data.Day.DayTradeInfo();
            bad8.Delete(th3.Id, db);
            #endregion


            #region 删除经纪公司日交易情况
            Data.Day.BrokerageDayTradeInfo bad11 = new Data.Day.BrokerageDayTradeInfo();
            bad11.Delete(th3.Id, db);
            #endregion

            #region 删除经纪公司月交易情况
            Data.Month.BrokerageMonthTradeInfo bad12 = new Data.Month.BrokerageMonthTradeInfo();
            bad12.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户月资金信息
            Data.Month.AccountMonthMoney bad13 = new Data.Month.AccountMonthMoney();
            bad13.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除账户年资金信息
            Data.Year.AccountYearMoney bad14 = new Data.Year.AccountYearMoney();
            bad14.Delete(th3.YPdate, db);
            #endregion


            #region 删除账户周预期
            Data.Month.AccountMonthExpected bad15 = new Data.Month.AccountMonthExpected();
            bad15.Delete(th3.MPdate, th3.YPdate, db);
            #endregion


            #region 删除账户月预期
            Data.Week.AccountWeekExpected bad16 = new Data.Week.AccountWeekExpected();
            bad16.Delete(th3.WPdate, th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除收益率持仓时间分析数据
            Data.Day.YieldInHoldTime ta = new Data.Day.YieldInHoldTime();
            ta.DeleteYieldHoldTime(tradeHistoryId, db);
            #endregion

            #region 删除小组日均值
            View.GroupDayAvg gda = new View.GroupDayAvg();
            gda.Delete(tradeHistoryId, db);
            #endregion

            #region 删除小组五日均值
            View.GroupFiveDayAvg gfda = new View.GroupFiveDayAvg();
            gfda.Delete(tradeHistoryId, db);
            #endregion

            #region 删除同批次交易员年均值
            Data.Year.BatchAvgYear bay = new Data.Year.BatchAvgYear();
            bay.Delete(th3.YPdate, db);
            #endregion


            #region 删除小组年均值
            Data.Year.GroupAvgYear gay = new Data.Year.GroupAvgYear();
            gay.Delete(th3.YPdate, db);
            #endregion

            #region 删除公司年均值
            Data.Year.CompanyYearAvg cay = new Data.Year.CompanyYearAvg();
            cay.Delete(th3.YPdate, db);
            #endregion

            #region 删除公司日数据
            Data.Day.CompanyDayChange cdc = new Data.Day.CompanyDayChange();
            cdc.Delete(th3.Id, db);
            #endregion

            #region 删除公司月数据
            Data.Month.CompanyMonthSum cms = new Data.Month.CompanyMonthSum();
            cms.Delete(th3.YPdate, th3.MPdate, db);
            #endregion

            #region 删除公司年数据
            Data.Year.CompanyYearSum cys = new Data.Year.CompanyYearSum();
            cys.Delete(th3.YPdate, db);
            #endregion

            #region 删除交易员周均值
            View.OperatorAvgWeek gda2 = new View.OperatorAvgWeek();
            gda2.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员日分析数据
            View.OperatorDayChange gda3 = new View.OperatorDayChange();
            gda3.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员日多空数据
            View.OperatorDayDirectionInfo gda4 = new View.OperatorDayDirectionInfo();
            gda4.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员日资金信息
            View.OperatorDayMoney moneya = new View.OperatorDayMoney();
            moneya.Delete(tradeHistoryId, db);
            #endregion


            #region 初始化交易员月资金信息
            View.OperatorMonthMoney moneyb2 = new View.OperatorMonthMoney();
            moneyb2.Delete(th3.YPdate, th3.MPdate, db);
            #endregion

            #region 初始化交易员年资金信息
            View.OperatorYearMoney moneyc = new View.OperatorYearMoney();
            moneyc.Delete(th3.YPdate, db);
            #endregion

            #region 删除化交易员持仓信息
            View.OperatorDayPosition moneyb = new View.OperatorDayPosition();
            moneyb.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员Tick数据
            View.OperatorDayTick tick3 = new View.OperatorDayTick();
            tick3.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员月Tick数据
            View.OperatorMonthTick tick4 = new View.OperatorMonthTick();
            tick4.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除交易员年Tick数据
            View.OperatorYearTick tick5 = new View.OperatorYearTick();
            tick5.Delete(th3.YPdate, db);
            #endregion

            #region 删除交易员日品种交易情况
            View.OperatorDayProductInfo opdayproductinfo = new View.OperatorDayProductInfo();
            opdayproductinfo.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员月品种交易情况
            View.OperatorMonthProductInfo opmonthproductinfo = new View.OperatorMonthProductInfo();
            opmonthproductinfo.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员年品种交易情况
            View.OperatorYearProductInfo opyearproductinfo = new View.OperatorYearProductInfo();
            opyearproductinfo.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员五日均值
            View.OperatorFiveDayAvg opavg = new View.OperatorFiveDayAvg();
            opavg.Delete(tradeHistoryId, db);
            #endregion

            #region 删除交易员月值
            View.OperatorMonthAvg opmonthavg = new View.OperatorMonthAvg();
            opmonthavg.Delete(th3.YPdate, th3.MPdate, db);
            #endregion

            #region 删除交易员周总计
            View.OperatorWeekSum opweeksum = new View.OperatorWeekSum();
            opweeksum.Delete(th3.YPdate, th3.MPdate, th3.WPdate, db);
            #endregion


            #region 删除交易月总计
            View.OperatorMonthSum opmonthsum = new View.OperatorMonthSum();
            opmonthsum.Delete(th3.MPdate, th3.YPdate, db);
            #endregion

            #region 删除交易员年总计
            View.OperatorYearSum oys = new View.OperatorYearSum();
            oys.Delete(th3.YPdate, db);
            #endregion

            #region 删除交易员年均值
            View.OperatorYearAvg oys2 = new View.OperatorYearAvg();
            oys2.Delete(th3.YPdate, db);
            #endregion

            #region 删除交易员年预期
            View.OperatorYearExpected oys3 = new View.OperatorYearExpected();
            oys3.Delete(th3.Id, db);
            #endregion

            #region 删除交易员周预期
            View.OperatorWeekExpected owe = new View.OperatorWeekExpected();
            owe.Delete(th3.YPdate, th3.MPdate, th3.WPdate, db);
            #endregion

            #region 删除交易员月预期
            View.OperatorMonthExpected ome = new View.OperatorMonthExpected();
            ome.Delete(th3.YPdate, th3.MPdate, db);
            #endregion

            #region 删除公司五日均值
            Data.Day.CompanyFiveDayAvg cavg = new Data.Day.CompanyFiveDayAvg();
            cavg.Delete(th3.Id, db);
            #endregion

            #region 删除公司周累计
            Data.Week.CompanyWeekSum cws = new Data.Week.CompanyWeekSum();
            cws.Delete(th3.YPdate, th3.WPdate, db);
            #endregion

            #region 删除经济公司年累计
            Data.Year.BrokerageYearTradeInfo cws2 = new Data.Year.BrokerageYearTradeInfo();
            cws2.Delete(th3.YPdate, db);
            #endregion

            #endregion

            //   new BenefitHelper.Sys.OperatorCouldSeeGroups().Delete(db);

            #region 删除保存时间
            Sys.TradeHistory th = new Sys.TradeHistory();
            th.Delete(pdate, db);
            #endregion
        }

        #region 得到还没有在分析系统存在的账号
        /// <summary>
        /// 得到还没有在分析系统存在的账号
        /// </summary>
        /// <returns></returns>
        private List<Data.ServerData.T_Account> GetUnRegistAccounts(DB.DBManager db)
        {
            List<Data.ServerData.T_Account> accounts = new List<Data.ServerData.T_Account>();//保存还未注册的账户
            List<Data.ServerData.T_Account> serverAccounts = new Data.ServerData.T_Account().GetList();//获取所有账户
            List<Sys.Account> benefitaccounts = new Sys.Account().GetList();
            foreach (Data.ServerData.T_Account t in serverAccounts)
            {
                bool isExist = false;
                var query = from s in benefitaccounts where t.LoginAccount.Equals(s.AccountName) select s;
                if (query.Count() > 0)
                {
                    isExist = true;
                }
                if (!isExist)
                {
                    accounts.Add(t);
                }
            }
            return accounts;
        }
        #endregion

        #region 得到还没有在分析系统存在的品种
        /// <summary>
        /// 得到还没有在分析系统存在的品种
        /// </summary>
        /// <returns></returns>
        private List<Data.ServerData.T_Product> GetUnRegistProducts(DB.DBManager db)
        {
            List<Data.ServerData.T_Product> products = new List<Data.ServerData.T_Product>();//保存还未注册的品种
            List<Data.ServerData.T_Product> serverProducts = new Data.ServerData.T_Product().GetList();//获取所有品种
            List<Sys.Product> benefitproducts = new Sys.Product().GetList(db);
            foreach (Data.ServerData.T_Product t in serverProducts)
            {
                bool isExist = false;
                var query = from s in benefitproducts where t.ProductID.Equals(s.ProductId) select s;
                if (query.Count() > 0)
                {
                    isExist = true;
                }
                if (!isExist)
                {
                    products.Add(t);
                }
            }
            return products;
        }
        #endregion

        #region 得到还没有在分析系统存在的合约
        /// <summary>
        /// 得到还没有在分析系统存在的合约
        /// </summary>
        /// <returns></returns>
        private List<Data.ServerData.T_Instrument> GetUnRegistInstruments(DB.DBManager db)
        {
            List<Data.ServerData.T_Instrument> instruments = new List<Data.ServerData.T_Instrument>();//保存还未注册的合约
            List<Data.ServerData.T_Instrument> serverInstruments = new Data.ServerData.T_Instrument().GetList();//获取所有合约
            List<Sys.Instrument> benefitinstruments = new Sys.Instrument().GetList(db);
            foreach (Data.ServerData.T_Instrument t in serverInstruments)
            {
                bool isExist = false;
                var query = from s in benefitinstruments where t.InstrumentID.Equals(s.InstrumentId) select s;
                if (query.Count() > 0)
                {
                    isExist = true;
                }
                if (!isExist)
                {
                    instruments.Add(t);
                }
            }
            return instruments;
        }
        #endregion

        #region 得到还没有在分析系统存在的交易所
        /// <summary>
        /// 得到还没有在分析系统存在的交易所
        /// </summary>
        /// <returns></returns>
        private List<Data.ServerData.T_Exchange> GetUnRegistExchanges(DB.DBManager db)
        {
            List<Data.ServerData.T_Exchange> exchanges = new List<Data.ServerData.T_Exchange>();//保存还未注册的合约
            List<Data.ServerData.T_Exchange> serverExchanges = new Data.ServerData.T_Exchange().GetList();//获取所有server保存的交易所
            List<Sys.Exchange> benefitExchanges = new Sys.Exchange().GetList(db);
            foreach (Data.ServerData.T_Exchange t in serverExchanges)
            {
                bool isExist = false;
                var query = from s in benefitExchanges where t.ExchangeID.Equals(s.ExchangeId) select s;
                if (query.Count() > 0)
                {
                    isExist = true;
                }
                if (!isExist)
                {
                    exchanges.Add(t);
                }
            }
            return exchanges;
        }
        #endregion


        ///// <summary>
        ///// 测试数据
        ///// </summary>
        //public void InitMyData(DB.DBManager db)
        //{
        //    BenefitHelper.Sys.Operator op = new BenefitHelper.Sys.Operator();
        //    op.Email = "xxxx@163.com";
        //    op.Password = "xxxx";
        //    op.Phone = "xxxx";
        //    op.Sex = "男";
        //    op.UName = "滕汤庆";
        //    op.Username = "xxxx";
        //    int opid = op.AddOperator(db);

        //    //int opid = 1;

        //    BenefitHelper.Sys.Account account = new BenefitHelper.Sys.Account();
        //    int accountid = account.GetAccountId("sss");
        //    //   int accountid = 15;
        //    BenefitHelper.Sys.OperatorAccount oa = new BenefitHelper.Sys.OperatorAccount();
        //    oa.OperatorId = opid;
        //    oa.AccountId = accountid;
        //    oa.AddOperatorAccount(db);


        //    //BenefitHelper.Sys.Operator op2 = new BenefitHelper.Sys.Operator();
        //    //op2.Email = "yyyy@163.com";
        //    //op2.Password = "yyyy";
        //    //op2.Phone = "yyyy";
        //    //op2.Sex = true;
        //    //op2.UName = "yyyy";
        //    //op2.Username = "yyyy";
        //    //int opid2 = op2.AddOperator();
        //    //int accountid2 = account.GetAccountId("mary03");
        //    //BenefitHelper.Sys.OperatorAccount oa2 = new BenefitHelper.Sys.OperatorAccount();
        //    //oa2.OperatorId = opid2;
        //    //oa2.AccountId = accountid2;
        //    //oa2.AddOperatorAccount();

        //    //BenefitHelper.Sys.Operator op3 = new BenefitHelper.Sys.Operator();
        //    //op3.Email = "zzzz@163.com";
        //    //op3.Password = "zzzz";
        //    //op3.Phone = "zzzz";
        //    //op3.Sex = true;
        //    //op3.UName = "zzzz";
        //    //op3.Username = "zzzz";
        //    //int opid3 = op3.AddOperator();
        //    //int accountid3 = account.GetAccountId("mary01");
        //    //BenefitHelper.Sys.OperatorAccount oa3 = new BenefitHelper.Sys.OperatorAccount();
        //    //oa3.OperatorId = opid3;
        //    //oa3.AccountId = accountid3;
        //    //oa3.AddOperatorAccount();


        //    //BenefitHelper.Sys.Operator op4 = new BenefitHelper.Sys.Operator();
        //    //op4.Email = "aaaa@163.com";
        //    //op4.Password = "aaaa";
        //    //op4.Phone = "aaaa";
        //    //op4.Sex = true;
        //    //op4.UName = "aaaa";
        //    //op4.Username = "aaaa";
        //    //int opid4 = op4.AddOperator();
        //    //int accountid4 = account.GetAccountId("mary02");
        //    //BenefitHelper.Sys.OperatorAccount oa4 = new BenefitHelper.Sys.OperatorAccount();
        //    //oa4.OperatorId = opid4;
        //    //oa4.AccountId = accountid4;
        //    //oa4.AddOperatorAccount();


        //    BenefitHelper.Sys.Groups g = new BenefitHelper.Sys.Groups();
        //    g.GroupName = "测试组1";
        //    g.ParentGroupId = 0;
        //    g.HasChildren = true;
        //    int gid = g.AddGroup(db);


        //    BenefitHelper.Sys.Groups g2 = new BenefitHelper.Sys.Groups();
        //    g2.GroupName = "测试组2";
        //    g2.ParentGroupId = 0;
        //    g2.HasChildren = false;
        //    int gid2 = g2.AddGroup(db);

        //    BenefitHelper.Sys.Groups g3 = new BenefitHelper.Sys.Groups();
        //    g3.GroupName = "测试组3";
        //    g3.ParentGroupId = 0;
        //    g3.HasChildren = false;
        //    int gid3 = g3.AddGroup(db);

        //    BenefitHelper.Sys.Groups g4 = new BenefitHelper.Sys.Groups();
        //    g4.GroupName = "测试组4";
        //    g4.ParentGroupId = gid;
        //    g4.HasChildren = false;
        //    int gid4 = g4.AddGroup(db);

        //    BenefitHelper.Sys.GroupOperators gop1 = new BenefitHelper.Sys.GroupOperators();
        //    gop1.GroupId = gid;
        //    gop1.OperatorId = opid;
        //    gop1.AddGroupOperators(db);

        //    //BenefitHelper.Sys.GroupOperators gop2 = new BenefitHelper.Sys.GroupOperators();
        //    //gop2.GroupId = gid2;
        //    //gop2.OperatorId = opid2;
        //    //gop2.AddGroupOperators();


        //    //BenefitHelper.Sys.GroupOperators gop3 = new BenefitHelper.Sys.GroupOperators();
        //    //gop3.GroupId = gid3;
        //    //gop3.OperatorId = opid3;
        //    //gop3.AddGroupOperators();



        //    //BenefitHelper.Sys.GroupOperators gop4 = new BenefitHelper.Sys.GroupOperators();
        //    //gop4.GroupId = gid;
        //    //gop4.OperatorId = opid4;
        //    //gop4.AddGroupOperators();

        //    Sys.OperatorCouldSeeGroups gg1 = new Sys.OperatorCouldSeeGroups();
        //    gg1.OperatorId = opid;
        //    gg1.GroupId = gid;
        //    gg1.Add(db);

        //    Sys.OperatorCouldSeeGroups gg2 = new Sys.OperatorCouldSeeGroups();
        //    gg2.OperatorId = opid;
        //    gg2.GroupId = gid2;
        //    gg2.Add(db);
        //}
    }
}
